# 定义商品类
class Commodity:
    def __init__(self, name, unit, price):
        self.name = name            # 名称
        self.unit = unit            # 计量单位
        self.price = float(price)     # 单价
        self.sales_volume = 0.0       # 销售量
        self.sales_amount = 0.0      # 销售金额

# 定义销售统计类
class Sale_Statistics(Commodity):
    total_revenue = 0.0             # 总营业额

    def __init__(self):
        self.commodities = []       # 统计商品类

    # 添加商品
    def add_commodity(self, commodity):
        self.commodities.append(commodity)

    # 删除商品
    def remove_commodity(self, name):
        for commodity in self.commodities:
            if commodity.name == name:
                self.commodities.remove(commodity)
                break

    # 销售
    def sell_commodity(self, name, quantity):
        for commodity in self.commodities:
            if commodity.name == name:
                total_price = commodity.price * quantity        # 总价
                commodity.sales_volume += quantity              # 销售量
                commodity.sales_amount += total_price           # 销售金额
                Sale_Statistics.total_revenue += total_price    # 总销售额
                break
            
    # 显示商品信息
    def display_commodities(self):
        for commodity in self.commodities:
            print(f"商品名称: {commodity.name}, 计量单位: {commodity.unit}, 单价: {commodity.price}")

    # 显示销售统计信息
    def display_sales_statistics(self):
        print("销售统计:")
        for commodity in self.commodities:
            print(f"商品名称: {commodity.name}, 销售量: {commodity.sales_volume}, 销售金额: {commodity.sales_amount}")
        print(f"总营业额: {Sale_Statistics.total_revenue}")



